Creating Animations with C-Light 0) Introduction 1) Design and Generation. 2) Creating an ANIM file. 3) Playback of animation. 4) An example. 5) A tutorial on using ED. 0) Introduction There are two disks included as part of C-Light. The disk labeled C-Light contains the scene editor, ray-tracer and View and Video tools. The second disk, labeled Animate contains the animation creation tools MakeAnim and PlayAnim as well as some demonstrations and examples. Be sure to create backup copies of the disks before proceeding. It is recommended that you read the C-Light manual before reading this document. To view the demonstration movies on the Animate disk, open the Movies drawer and double click on the icon of the movie you wish to view. The screen will turn black while the movie is being loaded into memory, then the first frame will appear. To start the movie, click once with the left mouse button. To stop the movie, click again with the left mouse button. This document is an addendum to the C-Light manual, serving to explain the use of the MakeAnim and PlayAnim tools for creating your own animated movies. (The terms movie and animation will be used interchangably in the following text as will the terms picture and frame.) Animations can be created in any mode (low-res, non-interlaced, interlaced, overscanned.) IFF pictures created with other programs can be included in an animation also. Note that you can NOT mix modes within an animation. If the first frame is low-res and non-interlaced then the rest of the frames must be low-res and interlaced. Interlaced animations will have a tendency to be slower because more of the screen has to be changed. Also, having two floppy disk drives is almost essential (although a RAM disk can probably be used in place of a second floppy drive.) 1) Design and Generation The first step in creating an animation is to dream up some idea that you would like to see animated. This is probably the part of any task that is the most fun. Once you have the idea you then have to figure out how to make it happen with the tools and resources you have available. Producing animations with C-Light involves breaking the motion in the movie you are going to create into individual frames that are slightly seperated in time; just like the frames of film in a reel of movie film. Each frame is slightly different from the previous one so that when shown rapidly in sequence, the eye is tricked into seeing smooth motion on the screen. Probably the best way to create this sequence of images with C-Light is a technique known as key-framing. Key-framing allows you to control motion by picking out the most important moments (or key frames) in the movie and using these to determine the locations of all the objects for all the frames inbetween. Thus, for example, to create a movie of a sphere and cube melting together, you might pick a scene where the cube and sphere are seperate as one key frame and one where they are melted together as another key frame. Then, since these two key frames tell you the starting and ending locations for the cube and sphere, you can figure out (using some simple math) where the cube and sphere are located for all the frames inbetween the two key frames. For example, if the sphere starts at x = -100, y = 0, and z = 0 and stops at x = 0, y = 0, z = 0 and there are 8 frames inbetween the key frames (for a total of ten frames in the movie) then the positions for the sphere in each frame are: Frame X Position Y Position Z position 1 -100 0 0 2 -89 0 0 3 -78 0 0 4 -67 0 0 5 -56 0 0 6 -45 0 0 7 -34 0 0 8 -23 0 0 9 -12 0 0 10 0 0 0 In order to figure out how much the position changes for each frame, just divide the total change in position between key frames by the total number of frames minus one. Thus the x position for the sphere is: Position change = +100 ----------------------- = 11 (its ok to round it off) 10 frames total - 1 = 9 So starting at x = -100 the sphere moves 11 units to the right for each frame. The MakeAnim tool that will be used to combine the pictures into a single movie will automatically make the movie looped. This means that when the movie reachs the last frame it will go back to the beginning and start again. Thus if you want to make a movie that repeats the same motion over and over (like a spinning Enterprise) you have to make sure the last frame and first frame flow together smoothly. This just means that you have to have the same amount of motion between the first and last frames as between any of the inbetween frames. (For example, in the Enterprise animation, the ship rotates 1/16 turn each frame and when the movie reaches the last frame, another 1/16 turn will make it the same as the first frame. Thus when the first frame is played again right after the last frame, the motion looks smooth.) If you run the movie play back tool PlayAnim from CLI you can control precisely the number of times a movie will repeat before stopping (from 1 to 999,999 times.) Now this may sound like a lot of work and it can be if your picture is very complicated and there is a lot of motion in it. However, for most movies it will take only an hour or two to create the scene description files for all the frames once you get the hang of it. There are some simple tricks you can use to speed things up too. For example, to create the Enterprise animation (included on the Animate disk in the Movies drawer) a detailed picture of the Enterprise was first created. Then, instead of figuring out a new position for each part of the ship for each frame as the ship rotates, the VIEW function in C-LightII was used to rotate the whole ship for each frame. Thus, once the ship was created, it only took a few minutes to create all the scene description files for the animation (just change the VIEW rotation, save the picture, change the rotation, save, change, save, etc.) Being organised also helps keep things simple when creating an animation. Make up a list showing the position for each object for each frame and use it as a checklist when creating the scene description files for all the frames with C-LightI. Be sure to give each file a unique name that will make it easy to figure out what order they go in later. (Melt1, Melt2, Melt3...) Now, once the scene description files for all the frames have been created each picture has to be calculated using C-LightII. This is done in exactly the same way as it would be for a single picture so refer to the C-Light manual for instructions on calculating a picture. It's ok if the pictures fill up more than one disk as will be shown in the next section. You can see that if the scene is complicated (so that it takes a long time to calculate a single frame) then it can take a LONG time to calculate all the frames in a movie. To give you an idea of how long, the Enterprise animation took about one week to calculate, doing two pictures a day. You can speed things up by turning off shadows, using less lights and using fewer objects. The reason it is so slow is because of the incredible number of calculations that must be done. Each dot on the screen (pixel) requires about 100 calculations (for say, a picture of a room with one light and no shadows). Thus for a non-interlaced, non-overscanned (320 pixels by 200 pixels) movie with 16 frames this means: 100 * 320 * 200 * 16 = 100,024,000 calculations! Even an Amiga takes a little while to accomplish a task of this complexity! Movies also take up a lot of disk and RAM space. An Amiga with 512K of RAM can playback a movie no larger than about 210K. Larger movies can be played if you have more than 512K RAM. The largest movie that can be created by MakeAnim without a hard disk drive is the size of one floppy disk (880K). For the advanced user, an example program called Spheres.c is included to show how to create scene description files from a program. In this way you can animate hundreds of objects without having to shift them individually for each frame. By studying this program you can also learn the format of the scene description files written by 3)C-LightI and read in by 3)C-LightII. These files are standard ASCII text files and can be read and modified using any text editor. 2) Creating an ANIM file Once you have created all the individual frames for a movie, they have to be put together in the proper order and saved in a single file. Also, in order to fit as many as possible in the memory of your Amiga, the pictures have to be compressed into a more compact format. The ANIM format was devised to give us a standard way to compress movies into a common format. It achieves the compression of a sequence of pictures into a smaller space by storing only the differences between each frame instead of the entire picture. The MakeAnim utility has been included as a part of C-Light to automatically compress a sequence of pictures and create an ANIM file from them. To use MakeAnim there are two simple preparations you have to make. First, you need a blank disk that has been given the name TMP. (See the "Introduction to Amiga" manual for instructions on formating a blank disk and relabeling it or see the example in section 4.) This disk will be used as a temporary work space by MakeAnim. [To use MakeAnim with a hard disk drive, use the ASSIGN command to make your Amiga think that the TMP: disk is a subdirectory of your hard disk. For example: ASSIGN TMP: dh0:WorkArea/Movies The ASSIGN command must be issued from a CLI window. See section 5 below for instructions on creating a CLI window.] Second, you need to create a list that tells MakeAnim where to find all the pictures that make up your movie. If you have a text editor you can use it to create the list (make sure to save the file as text-only so that all the text formating characters are not included.) If you don't have a favorite text editor you can use the simple one that came with your Amiga. It is called ED and must be run from a CLI window. If you are not familiar with ED or running programs from the CLI, see section 5 below for an easy step by step tutorial on using ED. This list, which tells MakeAnim where to find all the pictures in your movie, is called a script file. It has the following format: DiskName:Movie_Name Time DiskName:Frame_1_Name Time DiskName:Frame_2_Name Time DiskName:Frame_3_Name Time DiskName:Frame_4_Name Time DiskName:Frame_5_Name etc... The first line tells MakeAnim what the name of the final ANIM file will be and where to put it. The disk name can also include the names of drawers (subdirectories) such as: Movies:Melt_Drawer/Melt1.ilbm The next lines tell where the pictures are, what order they go in, and how long each one should stay on the screen. Again, the disk name can include drawers. The order of the pictures is the same as their order in the script file (the first one will be shown first, the second one second, etc.) The time entry is a number that tells how long each picture should stay on the screen. This gives you complete control over how fast things change in any part of your movie. The time is in multiples of one sixtyth of a second (1/60 second). Thus an entry of zero means to show the current frame as fast as possible, an entry of one means wait 1/60 second before going to the next frame, an entry of 2 means wait 2/60 second before going to the next frame, etc. So if you want the movie to run at about the same speed as a movie projector (24 frames/second) try a time value of three. The following is an example of a complete script file: Animate:Enterprise 0 WorkDisk_1:Enterprise/Enterprise1.ilbm 0 WorkDisk_1:Enterprise/Enterprise2.ilbm 0 WorkDisk_1:Enterprise/Enterprise3.ilbm 0 WorkDisk_1:Enterprise/Enterprise4.ilbm 0 WorkDisk_1:Enterprise/Enterprise5.ilbm 0 WorkDisk_1:Enterprise/Enterprise6.ilbm 0 WorkDisk_1:Enterprise/Enterprise7.ilbm 0 WorkDisk_1:Enterprise/Enterprise8.ilbm 0 WorkDisk_2:Enterprise9.ilbm 0 WorkDisk_2:Enterprise10.ilbm 0 WorkDisk_2:Enterprise11.ilbm 0 WorkDisk_2:Enterprise12.ilbm 0 WorkDisk_2:Enterprise13.ilbm 0 WorkDisk_2:Enterprise14.ilbm 0 WorkDisk_2:Enterprise15.ilbm 60 WorkDisk_2:Enterprise16.ilbm Note that the pictures are located on two different disks in this example (WorkDisk_1: amd WorkDisk_2:). Also, on WorkDisk_1: the pictures are in a subdirectory (drawer) while on WorkDisk_2: they are in the main level directory. It is a good idea to have the final ANIM file reside on a different disk from those containing the pictures so that you don't run out of space. The time values are all set to zero so that the movie will run as fast as possible except for the last one which is set to 60. This means that the movie will pause for one second on the last frame before going back to the first frame. (There can be as many spaces as you like between time and picture name, but there must be at least one!) All these variations show the flexibility that is allowed in creating a script file. Once you have created the script file, run MakeAnim. If you run it from Workbench it will ask you for the name of the script file (a disk name and/or drawer name can be included too.) [If you want to run from CLI, just run MakeAnim and it will give you instructions.] Once MakeAnim has the script file name, the rest of the process is automatic. A window will open that will tell what is currently going on in the process of compressing and storing the pictures. At various points in the process you will be asked to insert different disks so that MakeAnim can access them (first it will look at all the pictures and write out some temporary files to the TMP disk, then it will take one picture and all the TMP files and create the final ANIM file on the output disk.) This process really requires two disk drives. It is possible to do it with only one, but you'll wear your arm out swapping disks. If you have a RAM expansion the RAM disk can be used as a second drive. Just copy all the pictures to the RAM disk and use RAM: for the disk name in the script file. Alternatively, you can use the ASSIGN command to make your Amiga think the RAM disk is the TMP disk. Just issue the command: ASSIGN TMP: RAM: from a CLI window. See section 5 below for instructions on opening a CLI window. Even with two disk drives you should be intelligent about which drive you put a disk into. Try to place disks in a drive such that you never have two disks being accessed from the same drive. For example, MakeAnim first asks for a picture disk, then asks for the TMP disk. Don't put the TMP disk in the same drive as the picture disk or you will have to constantly swap them. Instead, place it in the second drive and everything will procede smoothly. Similarly, don't put the TMP and the final output disk in the same drive. You can stop the process at any time by typing Control-C (hold down the CTRL key and the C key at the same time.) The process is relatively quick; it usually takes only five to twenty minutes to create the final ANIM file depending on the length of the movie and the amount of motion that occurs within it. 3) Playback of Animation The PlayAnim tool is used to show your movie after the ANIM file has been created. There are two different ways to play it back from Workbench. [To playback from CLI, just run PlayAnim and it will give you instructions.] In the first method you simply double click on the icon for the animation you have created. This requires that a copy of PlayAnim is in the main window for the disk that contains the ANIM file (or you can change the tool type for the movie to point to the disk that has PlayAnim on it.) To use the second method, just double click on the PlayAnim icon. A requestor will ask you for the location/name of the ANIM file you wish to view. Once the ANIM file has been read in by PlayAnim, the first frame of the movie will appear. To start it playing, just click in the screen once with the left mouse button. When you want the movie to stop, click again with the left mouse button. This method is designed to give you the most precise control of start and stop times when patching together several movies into a longer movie on your video tape recorder. More precise control of the number of times the movie repeats is possible by running PlayAnim from CLI. Also, you may notice that the movie flickers a little when shown on your Amiga monitor. This is because interlace is automatically turned on by PlayAnim in order to get the best quality when recording on a video tape recorder. The interlace feature can optionally be turned off when PlayAnim is run from CLI. (Run PlayAnim from CLI to get instructions on how to set these options.) 4) An Example This section describes how to create a movie using some example pictures included on the Animate disk. For demonstration purposes a set of pictures, showing a ball spinning around a rotating cube, has been included in the Pictures drawer on the Animate disk. A script file and the C-LightI scene description files have also been included in this drawer. Make sure your copy of the Animate disk is labeled Animate; use the Rename item in the Workbench menu to rename it if it is not. First create a TMP disk by putting a blank disk in your Amiga, select the disk icon that appears and then select Initialize from Workbench's Disk menu. Then select Rename from the Workbench menu and change the disk name from blank to TMP. Now, to turn the pictures into an animated movie, double click on the MakeAnim icon. A requestor will appear asking for the name of the script file. Enter the name: Animate:Pictures/b.script which gives the name and location of the script file. You can use an editor to look at this script file as a working example (see section 5 if you don't know how to use a text editor.) The script file contains the locations/names of all the pictures that will be used to make the movie and tells MakeAnim to put the completed movie in the main window (top level directory) of the Animate disk and to call it Ball&Cube. After you have typed in the name, hit return and a small text window will appear. This window will keep you informed on the progress of the movie you are creating. After reading in the names of the picture files, MakeAnim will ask for the TMP disk to be inserted. Because there is a lot of blank screen in this movie and not much motion, both the pictures and the final movie will fit on the Animate disk with room to spare. First the pictures will be read in one at a time and compressed and stored a s DLTA files on the TMP disk. Then the first picture and all the DLTA files will be combined into an ANIM file and stored on the Animate disk. When the process is complete, close the window for the Animate disk and then reopen it. There should now be an icon there that looks like a reel of movie film. Double click on that icon to play back the movie you just created. (See section 3 above for complete instructions on play back of movies.) That's all there is to it! 5) A Tutorial on using ED ED is a simple text editor that is included on your Workbench disk. It is only callable from a CLI window (Command Line Interface window.) The following steps can be used to create or examine a script file using ED: 1) To get a CLI window call up Preferences and select CLI ON (see the "Introduction to Amiga" manual for information on using Preferences.) Exit Preferences by selecting SAVE, then close the Workbench window and reopen it. Open the drawer labeled SYSTEM. A new icon will appear there from now on called CLI. Open a CLI window by double clicking on this icon. 2) Click once in the CLI window to activate it, then type: CD disk:drawer where "disk" is the name of the disk you want to put the script file on and "drawer" is the name of the drawer you would like it to be in (leave out the drawer name if you want the script file to be in the top level directory of the disk.) Now type: ED filename (where "filename" is the name of your script file) and then hit RETURN. 3) You are now in the ED editor and can type in the disk names, drawer names, picture names and times for the script file. You can use the cursor keys (with the arrows on them) to move around while typing and can use the BACKSPACE and DEL keys to erase mistakes. Holding down CTRL and B at the same time will delete a whole line. When you are done you can save your work to disk by hitting the ESC key, then the X key, then RETURN. 4) You are now back in the CLI window. If you want to close the CLI window, type ENDCLI. If you run into trouble at any time and want to get out of ED, just type ESC, then X, then RETURN. See the "AmigaDOS Users Manual" if you would like more information on using ED.